<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>我的订单</title>
    <link rel="icon" href="../img/favicon.ico">

    <link rel="stylesheet" type="text/css" href="../css/all.css"/>
    <link rel="stylesheet" type="text/css" href="../css/pages-myOrder.css"/>

    <script src="../js/vue.js"></script>
    <script src="../js/axios.js"></script>

    <!--elementUI东西-->
    <script src="//unpkg.com/vue/dist/vue.js"></script>
    <script src="//unpkg.com/element-ui@2.15.7/lib/index.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>

<body>
<!-- 头部栏位 -->
<!--页面顶部-->
<div id="app">
    <div id="nav-bottom">
        <!--顶部-->
        <div class="nav-top">
            <div class="top">
                <div class="py-container">
                    <div class="shortcut">
                        <ul class="fl">
                            <li class="f-item">汇才商城欢迎您！</li>
                            <li class="f-item">
                                <a th:if="${session.user!=null}" href="#" th:text="${session.user.userName}"></a>
                                <a th:if="${session.user==null}" href="login.html">登录</a>
                                <span>
								<a th:if="${session.user==null}" href="register.html">免费注册</a>
								<a th:if="${session.user!=null}" href="javascript:;" onclick="userLogout()">退出</a>
							</span>
                            </li>
                        </ul>
                        <div class="fr typelist">
                            <ul class="types">
                                <li class="f-item">
                                <span>
                                    <a href="myOrder.html" target="_blank">我的订单</a>
                                </span>
                                </li>

                                <li class="f-item"><span><a href="cart.html" target="_blank">我的购物车</a></span></li>
                                <li class="f-item"><span><a href="home.html" target="_blank">我的汇才</a></span></li>
                                <li class="f-item"><span>汇才会员</span></li>
                                <li class="f-item"><span>企业采购</span></li>
                                <li class="f-item"><span>关注汇才</span></li>
                                <li class="f-item"><span><a href="cooperation.html" target="_blank">合作招商</a></span></li>
                                <li class="f-item"><span><a href="shoplogin.html" target="_blank">商家后台</a></span></li>
                            </ul>
                        </div>

                    </div>
                </div>
            </div>

            <!--头部-->
            <div class="header">
                <div class="py-container">
                    <div class="yui3-g Logo">
                        <div class="yui3-u Left logoArea">
                            <a class="logo-bd" title="汇才商城" href="index.html"></a>
                        </div>
                        <div class="yui3-u Rit searchArea">
                            <div class="search">
                                <form action="" class="sui-form form-inline">
                                    <!--searchAutoComplete-->
                                    <div class="input-append">
                                        <input type="text" id="autocomplete" class="input-error input-xxlarge"/>
                                        <button class="sui-btn btn-xlarge btn-danger" type="button">搜索</button>
                                    </div>
                                </form>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>

    <!--header-->
    <div id="account">
        <div class="py-container">
            <div class="yui3-g home">
                <!--左侧列表-->
                <div class="yui3-u-1-6 list">
                    <dl>
                        <dt><i>·</i> 订单中心</dt>
                        <dd>我的订单</dd>
                        <dd>团购订单</dd>
                        <dd>本地生活订单</dd>
                        <dd>我的预售</dd>
                        <dd>评价晒单</dd>
                        <dd>取消订单记录</dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 关注中心</dt>
                        <dd>关注的商品</dd>
                        <dd>关注的店铺</dd>
                        <dd>关注的专辑</dd>
                        <dd>关注的品牌</dd>
                        <dd>关注的活动</dd>
                        <dd>浏览历史</dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 特色业务</dt>
                        <dd>我的营业厅</dd>
                        <dd>京东通信</dd>
                        <dd>定期送</dd>
                        <dd>京东代下单</dd>
                        <dd>我的回收单</dd>
                        <dd>节能补贴</dd>
                        <dd>医药服务</dd>
                        <dd>流量加油站</dd>
                        <dd>黄金托管</dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 客户服务</dt>
                        <dd>返修退换货</dd>
                        <dd>价格保护</dd>
                        <dd>意见建议</dd>
                        <dd>购买咨询</dd>
                        <dd>交易纠纷</dd>
                        <dd>我的发票</dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 设置</dt>
                        <dd>个人信息</dd>
                        <dd>收货地址</dd>
                    </dl>
                </div>
                <!--右侧主内容-->
                <div class="yui3-u-5-6 body">
                    <div class="order">
                        <div class="mt">
                            <span class="fl"><strong>我的订单</strong></span>
                        </div>
                    </div>

                    <div class="order-detail" id="item">

                        <div class="ever">
                            <div class="tab-content">
                                <div class="chosetype">
                                    <table class="sui-table table-bordered-simple">
                                        <thead>
                                        <tr>
                                            <th width="29%">商品</th>
                                            <th width="31%">订单详情</th>
                                            <th width="13%">收货人</th>
                                            <th>金额</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        </tbody>
                                    </table>
                                </div>
                                <div id="all" class="tab-pane active">
                                    <div class="orders">
                                        <!--显示订单详情-->
                                        <table class="sui-table table-bordered" v-for="order in orderList">
                                            <thead>
                                            <tr>
                                                <th colspan="5">
                                                <span class="ordertitle">{{order.orderDate}}　订单编号：{{order.orderId}} <span
                                                        class="pull-right delete"><img src="../img/delete.png"/></span></span>
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr v-if="order.orderDetailList.length>0">
                                                <td width="60%">
                                                    <div class="typographic">
                                                        <img :src="order.orderDetailList[0].product.productPicture" style="width: 80px"/>
                                                        <a href="#" style="display: block;width: 60%">{{order.orderDetailList[0].product
                                                            .productIntroduction}}</a>
                                                        <span>x{{order.orderDetailList[0].purchaseNum}}</span>
                                                        <ul class="unstyled list-inline">
                                                            <li><a style="color: black">申请售后</a></li>
                                                        </ul>
                                                    </div>
                                                </td>
                                                <td :rowspan="order.orderDetailList.length" width="8%" class="center">{{order.user
                                                    .userName}}</td>
                                                <td :rowspan="order.orderDetailList.length" width="13%" class="center">
                                                    <ul class="unstyled">
                                                        <li>总金额¥{{(Math.round(order.totalMoney*100)/100).toFixed(2)}}</li>
                                                        <li>在线支付</li>
                                                    </ul>
                                                </td>
                                                <td :rowspan="order.orderDetailList.length" width="8%" class="center">
                                                    <a href="#" class="btn">
                                                        {{order.orderStatus | showStatus}}
                                                    </a>
                                                </td>
                                                <td :rowspan="order.orderDetailList.length" width="13%" class="center">
                                                    <ul class="unstyled">
                                                        <li>
                                                            <a href="#" target="_blank">{{order.orderStatus |
                                                                userOperation}}</a>
                                                        </li>
                                                    </ul>
                                                </td>
                                            </tr>
                                            <tr v-for="orderDetail in order.orderDetailList.slice(1)">
                                                <!--<td width="50%">
                                                    <div class="typographic"><img src="../img/goods.png"/>
                                                        <a href="#" class="block-text">包邮 正品玛姬儿压缩面膜无纺布纸膜100粒 送泡瓶面膜刷喷瓶 新款</a><span>x1</span>
                                                        <ul class="unstyled">
                                                            <li>申请售后</li>
                                                        </ul>
                                                    </div>
                                                </td>-->
                                                <td width="50%">
                                                    <div class="typographic">
                                                        <img :src="orderDetail.product.productPicture" style="width: 80px"/>
                                                        <a href="#" style="display: block;width: 60%">{{orderDetail.product
                                                            .productIntroduction}}</a>
                                                        <span>x{{orderDetail.purchaseNum}}</span>
                                                        <ul class="unstyled list-inline">
                                                            <li><a style="color: black">申请售后</a></li>
                                                        </ul>
                                                    </div>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="choose-order">
                                        <!--分页-->
                                        <div class="fr page">
                                            <el-pagination
                                                    @size-change="handleSizeChange"
                                                    @current-change="handleCurrentChange"
                                                    :current-page="currentPage"
                                                    :page-sizes="[2,10, 50, 100, 200]"
                                                    :page-size="pageSize"
                                                    layout="total, sizes, prev, pager, next, jumper"
                                                    :total="total">
                                            </el-pagination>
                                            </el-pagination>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>

                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="order">
                        <div class="mt">
                            <span class="fl"><strong>猜你喜欢</strong></span>
                        </div>
                    </div>
                    <div class="like-list">
                        <ul class="yui3-g">
                            <li class="yui3-u-1-4">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <img src="../img/_/itemlike01.png"/>
                                    </div>
                                    <div class="attr">
                                        <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i>3699.00</i>
                                        </strong>
                                    </div>
                                    <div class="commit">
                                        <i class="command">已有6人评价</i>
                                    </div>
                                </div>
                            </li>
                            <li class="yui3-u-1-4">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <img src="../img/_/itemlike02.png"/>
                                    </div>
                                    <div class="attr">
                                        <em>Apple苹果iPhone 6s/6s Plus 16G 64G 128G</em>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i>4388.00</i>
                                        </strong>
                                    </div>
                                    <div class="commit">
                                        <i class="command">已有700人评价</i>
                                    </div>
                                </div>
                            </li>
                            <li class="yui3-u-1-4">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <img src="../img/_/itemlike03.png"/>
                                    </div>
                                    <div class="attr">
                                        <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i>4088.00</i>
                                        </strong>
                                    </div>
                                    <div class="commit">
                                        <i class="command">已有700人评价</i>
                                    </div>
                                </div>
                            </li>
                            <li class="yui3-u-1-4">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <img src="../img/_/itemlike04.png"/>
                                    </div>
                                    <div class="attr">
                                        <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i>4088.00</i>
                                        </strong>
                                    </div>
                                    <div class="commit">
                                        <i class="command">已有700人评价</i>
                                    </div>
                                </div>
                            </li>
                            <li class="yui3-u-1-4">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <img src="../img/_/itemlike04.png"/>
                                    </div>
                                    <div class="attr">
                                        <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i>4088.00</i>
                                        </strong>
                                    </div>
                                    <div class="commit">
                                        <i class="command">已有700人评价</i>
                                    </div>
                                </div>
                            </li>
                            <li class="yui3-u-1-4">
                                <div class="list-wrap">
                                    <div class="p-img">
                                        <img src="../img/_/itemlike04.png"/>
                                    </div>
                                    <div class="attr">
                                        <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                    </div>
                                    <div class="price">
                                        <strong>
                                            <em>¥</em>
                                            <i>4088.00</i>
                                        </strong>
                                    </div>
                                    <div class="commit">
                                        <i class="command">已有700人评价</i>
                                    </div>
                                </div>
                            </li>

                        </ul>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <!-- 底部栏位 -->
    <!--页面底部-->
    <div class="clearfix footer">
        <div class="py-container">
            <div class="footlink">
                <div class="clearfix Mod-list">
                    <div class="yui3-g">
                        <div class="yui3-u-1-6">
                            <h4>购物指南</h4>
                            <ul class="unstyled">
                                <li>购物流程</li>
                                <li>会员介绍</li>
                                <li>生活旅行/团购</li>
                                <li>常见问题</li>
                                <li>购物指南</li>
                            </ul>

                        </div>
                        <div class="yui3-u-1-6">
                            <h4>配送方式</h4>
                            <ul class="unstyled">
                                <li>上门自提</li>
                                <li>211限时达</li>
                                <li>配送服务查询</li>
                                <li>配送费收取标准</li>
                                <li>海外配送</li>
                            </ul>
                        </div>
                        <div class="yui3-u-1-6">
                            <h4>支付方式</h4>
                            <ul class="unstyled">
                                <li>货到付款</li>
                                <li>在线支付</li>
                                <li>分期付款</li>
                                <li>邮局汇款</li>
                                <li>公司转账</li>
                            </ul>
                        </div>
                        <div class="yui3-u-1-6">
                            <h4>售后服务</h4>
                            <ul class="unstyled">
                                <li>售后政策</li>
                                <li>价格保护</li>
                                <li>退款说明</li>
                                <li>返修/退换货</li>
                                <li>取消订单</li>
                            </ul>
                        </div>
                        <div class="yui3-u-1-6">
                            <h4>特色服务</h4>
                            <ul class="unstyled">
                                <li>夺宝岛</li>
                                <li>DIY装机</li>
                                <li>延保服务</li>
                                <li>汇才E卡</li>
                                <li>汇才通信</li>
                            </ul>
                        </div>
                        <div class="yui3-u-1-6">
                            <h4>帮助中心</h4>
                            <img src="../img/wx_cz.jpg">
                        </div>
                    </div>
                </div>
                <div class="Mod-copyright">
                    <ul class="helpLink">
                        <li>关于我们<span class="space"></span></li>
                        <li>联系我们<span class="space"></span></li>
                        <li>关于我们<span class="space"></span></li>
                        <li>商家入驻<span class="space"></span></li>
                        <li>营销中心<span class="space"></span></li>
                        <li>友情链接<span class="space"></span></li>
                        <li>关于我们<span class="space"></span></li>
                        <li>营销中心<span class="space"></span></li>
                        <li>友情链接<span class="space"></span></li>
                        <li>关于我们</li>
                    </ul>
                    <p>© 2020 版权所有 广州汇才创智科技有限公司</p>
                    <p>粤ICP备20043971号</p>
                </div>
            </div>
        </div>
    </div>
</div>
<!--页面底部END-->
<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="../js/pages/index.js"></script>
<script>
    new Vue({
        el: "#app",
        data: {
            currentPage: 1,
            pageSize: 2,
            total: 0,
            orderList: [],
        },
        created() {
            this.getOrderByUserId();
        },
        methods: {
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
                this.pageSize = val;
                console.log(this.pageSize)
                this.getOrderByUserId();
            },
            handleCurrentChange(val) {
                this.currentPage = val;
                console.log(`当前页: ${val}`);
                this.getOrderByUserId();
            },
            getOrderByUserId(){
                let url = "/SpringBoot/user/getOrderByUid";
                let _this = this;
                let pager={
                    page:_this.currentPage,
                    pageRows:_this.pageSize,
                }
                axios.post(url,pager).then(function (response) {
                    if (response.data.success) {
                        _this.orderList = response.data.orderList;
                        _this.total=response.data.total;
                    } else {
                        alert(response.data.message)
                    }
                }).catch(function (error) {
                    console.log(error);
                })
            }
        },
        filters: {
            showStatus(status) {
                switch (status) {
                    case 0:
                        return "待付款";
                        break;
                    case 1:
                        return "待发货";
                        break;
                    case 2:
                        return "待收货";
                        break;
                    case 3:
                        return "待评价";
                        break;
                    case 4:
                        return "已完成";
                        break;
                    default:
                        return "状态异常";
                        break;
                }
            },
            userOperation(status) {
                if (status == 4)
                    return "评价|晒单";
                else if(status==0)
                    return "去付款";
                else return "确认收货";
            }
        }
    })

    /*退出登录*/
    function userLogout() {
        let flag = confirm("您确定要退出登录吗?")
        if (flag) {
            $.ajax({
                url: "/SpringBoot/user/userLogout",
                type: "post",
                dataType: "json",
                data: "",
                success: function (data) {
                    if (data.success) {
                        /*刷新当前页面*/
                        location.reload();
                    }
                },
                error: function () {
                    $("#message").html("数据获取失败");
                }
            })
        }
    }
</script>


</body>

</html>
